import {Component, Input, OnChanges, OnInit, Output, SimpleChanges, TemplateRef, ViewChild, ViewEncapsulation} from '@angular/core';

@Component({
  selector: 'ss-platform-select',
  templateUrl: './select.component.html',
  styleUrls: ['./select.component.scss'],
  host: {class: "ss-platform-select-wraper"},
  encapsulation: ViewEncapsulation.None
})
export class SelectComponent implements OnInit, OnChanges {

  @Input("icon")
  icon: string = "";
  @Input("options")
  options: Array<any>;
  @Input("selectedOption")
  @Output("selectedOption")
  selectedOption: any;
  @Input("placeholder")
  placeholder: string = "请选择";

  constructor() {
  }

  ngOnInit(): void {
  }

  ngOnChanges(changes: SimpleChanges): void {
    if (changes["options"]) {
      if (!this.selectedOption) {
        this.selectedOption = this.options.find(option => option.default);
      }
    }
  }

}
